home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 007a / 899track.zip / 899PRINT.PRO < prev    next >
Text File  |  1990-03-06  |  6KB  |  180 lines

  1. project "899"
  2. include "899glob.pro"
  3.  
  4.  
  5. % 899PRINT.PRO -- Printing module (for labels and sheets)
  6. %    USES window #61
  7. %   Global Predicates in this file...
  8. %       sheet_print
  9. %       label_print
  10.  
  11. DATABASE - printbase
  12.   determ linesPrinted(INTEGER)    % Number of lines printed
  13.   determ linesPerPage(INTEGER)    % Lines per page
  14.   determ printComments            % Boolean
  15.   determ fullListPrint            % Boolean (Used with catsToPrint)
  16.   determ catsToPrint(gsList)      % Categories to print (If not fullListPrint)
  17.   determ labelprint               % Boolean
  18.   
  19.  
  20. PREDICATES
  21.   set_s_options   % sheet_print options
  22.   set_l_options   % label_print options
  23.   print_engine
  24.   check_for_print(gsList)           % non determ
  25.   findmatch(gsList,gsList)
  26.   selectCats
  27.   page_eject(INTEGER)
  28.   label_check(INTEGER)
  29.   stop_check
  30.  
  31.  
  32. CLAUSES
  33.   sheet_print :-
  34.       makewindow(61,green,green," Printing ",6,0,18,79),
  35.       set_s_options,
  36.       clearwindow,
  37.       write("About to print list of record labels...position paper\n"),
  38.       wait,
  39.       clearwindow,
  40.       write("Press any key to stop printing...."),
  41.       writedevice(printer),
  42.       print_engine,
  43.       flush(printer),
  44.       writedevice(screen),
  45.       retractall(_,printbase),
  46.       removewindow.
  47.  
  48.   label_print :-
  49.       makewindow(61,green,green," Label Printing ",6,0,18,79),
  50.       set_l_options,
  51.       clearwindow,
  52.       write("Position labels in printer (1 accross)...\n"),
  53.       wait,
  54.       clearwindow,
  55.       write("Press any key to stop printing...."),
  56.       writedevice(printer),
  57.       print_engine,
  58.       flush(printer),
  59.       writedevice(screen),
  60.       retractall(_,printbase),
  61.       removewindow.
  62.       
  63.  
  64.   set_s_options :-
  65.       assert(linesPrinted(0),printbase),
  66.       assert(linesPerPage(66),printbase),
  67.       assert(printComments,printbase),
  68.       assert(catsToPrint([]),printbase),
  69.       selectCats, !.
  70.  
  71.   set_l_options :-
  72.       assert(labelprint,printbase),
  73.       assert(catsToPrint([]),printbase),
  74.       selectCats, !.
  75.   
  76.   selectCats :-
  77.         write("Do you want ALL categories of music printed (Y/N)? "),
  78.         not(askyn), !,
  79.       getMusicTypes(AllTypes),
  80.       Tit = "Use Cursors,\17\217 to select category for printing ",
  81.       getbacktrack(Btop),
  82.       repeat,
  83.         catsToPrint(CurrL),
  84.         clearwindow,
  85.         write("Current categories selected for printing --\n"),
  86.         writelist(CurrL,5),
  87.         show_get(AllTypes,MoreCats,Tit),
  88.         NewList = [MoreCats|CurrL],
  89.         retract(catsToPrint(_),printbase),
  90.         assert(catsToPrint(NewList),printbase),
  91.         write("New List is --\n"),
  92.         writelist(NewList,5),
  93.         write("Add more categories to print (Y/N)? "),
  94.       not(askyn),
  95.       cutbacktrack(Btop).
  96.   selectCats :- 
  97.       retract(catsToPrint(_),printbase), !,
  98.       assert(fullListPrint,printbase).  % And do this for ESC from above
  99.  
  100.  
  101.   print_engine :-
  102.       labelprint,
  103.       write("\027M\027x\001"),  % Condesed print, letter quality
  104.       label(Cats,Lab,Addr,City,State,Zip,_,_),  % For Each label
  105.         check_for_print(Cats),
  106.         write(Lab,'\n'),
  107.         writelist(Addr,0),
  108.         write(City,", ",State,"  ",Zip,'\n'),
  109.         listlen(Addr,Acount),
  110.         label_check(Acount),
  111.         stop_check,
  112.       fail.
  113.   print_engine :-
  114.       not(labelprint),
  115.       write('\012'),   % Page eject
  116.       label(Cats,Lab,Addr,City,State,Zip,Phone,Comments),  % For Each label
  117.         check_for_print(Cats),
  118.         listlen(Addr,Acount),         % Get the number of things to print here
  119.         listlen(Comments,Ccount),
  120.         listlen(Cats,Catcount),
  121.         Tcount = Acount + Ccount + Catcount + 6,
  122.         page_eject(Tcount),
  123.         write(Lab,"   ",Phone), nl,
  124.         writelist(Addr,0),
  125.         write(City,", ",State,' ',Zip), nl,
  126.         write("  CATEGORIES::\n"),
  127.         writelist(Cats,7),
  128.         write("  COMMENTS::\n"),
  129.         writelist(Comments,7), nl, nl,
  130.         stop_check,
  131.       fail.
  132.   print_engine :- write("\012\027@").  % Page eject, reset printer
  133.     
  134.   
  135.   check_for_print(_) :- % Succeds if full list is to be printed
  136.       fullListPrint, !.
  137.   check_for_print(Cats) :- % Above failed -- test for subset
  138.       catsToPrint(ListToPrint),  % Get this
  139.       findmatch(Cats,ListToPrint).
  140.   
  141.   findmatch([],_) :- !, fail.  % Such is what happens at ent of test list
  142.   findmatch([X|_],ListToPrint) :-
  143.       sameMusicCategory(X,ListToPrint), !.  % Succeds here, if 1 is in list
  144.   findmatch([_|Rest],ListToPrint) :-
  145.       findmatch(Rest,ListToPrint).  % Try the rest of the list if fails -- not there
  146.  
  147.   page_eject(LinesToPrint) :-
  148.       linesPrinted(Lprinted),   % Get how many done
  149.       linesPerPage(MaxLines),   % Get the maximum number of lines per page
  150.       NewTotal = LinesToPrint + Lprinted,
  151.       NewTotal > MaxLines, !,
  152.       write('\012'),  % Eject the page if so
  153.       retract(linesPrinted(Lprinted),printbase), !,  % Take old count out
  154.       assert(linesPrinted(LinesToPrint),printbase).  % A new page
  155.   page_eject(LinesToPrint) :-   % No page eject is neccesary
  156.       retract(linesPrinted(OldTotal),printbase), !,
  157.       NewTotal = OldTotal + LinesToPrint,
  158.       assert(linesPrinted(NewTotal),printbase).
  159.  
  160.   label_check(0) :- !,
  161.       write("\n\n\n\n").
  162.   label_check(1) :- !,
  163.       write("\n\n\n").
  164.   label_check(2) :- !,
  165.       write("\n\n").
  166.   label_check(_) :-
  167.       write("\n").
  168.  
  169.   stop_check :-
  170.       keypressed, !,  % A key was pressed....
  171.       inkey(_), !,    % Discard the keystroke
  172.       writedevice(screen),
  173.       clearwindow,
  174.       write("Would you like to abort the current print job (Y/N)? "),
  175.       askyn, !,
  176.       retractall(_,printbase), !,
  177.       assert(catsToPrint([]),printbase),
  178.       fail.
  179.   stop_check :- writedevice(printer).
  180.